package thread;

public class Demo15 {
    //我们之前是 main线程等待别的线程，那么别的线程能不能等待main呢？答案是能的我们来看
    public static void main(String[] args) throws InterruptedException {
        Thread mainThread = Thread.currentThread();

        Thread t = new Thread(() -> {
            try {
                System.out.println("开始等待 main结束");
                mainThread.join();//
                System.out.println("结束等待 main结束");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        t.start();

        Thread.sleep(3000);
        System.out.println("main结束");
    }
}
